%{
#include "wx/ctb/gpibx.h"
%}

%include iobase.i

enum wxGPIB_Timeout
{
    wxGPIB_TO_NONE = 0, 
    wxGPIB_TO_10us, 
    wxGPIB_TO_30us, 
    wxGPIB_TO_100us,
    wxGPIB_TO_300us,
    wxGPIB_TO_1ms,  
    wxGPIB_TO_3ms,  
    wxGPIB_TO_10ms, 
    wxGPIB_TO_30ms, 
    wxGPIB_TO_100ms,
    wxGPIB_TO_300ms,
    wxGPIB_TO_1s,   
    wxGPIB_TO_3s,   
    wxGPIB_TO_10s,  
    wxGPIB_TO_30s,  
    wxGPIB_TO_100s, 
    wxGPIB_TO_300s, 
    wxGPIB_TO_1000s
};

struct wxGPIB_DCS
{
    int m_address1;
    int m_address2;
    wxGPIB_Timeout m_timeout;
    bool m_eot;
    unsigned char m_eosChar;
    unsigned char m_eosMode;
    wxGPIB_DCS();
    char* GetSettings(char* buf,size_t bufsize);
}; 

enum {
    CTB_GPIB_SETADR = CTB_GPIB,
    CTB_GPIB_GETRSP,
    CTB_GPIB_GETSTA,
    CTB_GPIB_GETERR,
    CTB_GPIB_GETLINES,
    CTB_GPIB_SETTIMEOUT,
    CTB_GPIB_GTL,
    CTB_GPIB_REN,
    CTB_GPIB_RESET_BUS
};

class wxGPIB_x : public wxIOBase
{
protected:
    int m_board;
    int m_hd;
    int m_state;
    int m_error;
    int m_count;
    int m_asyncio;
    wxGPIB_DCS m_dcs;
public:
    wxGPIB_x();
    virtual ~wxGPIB_x();
    const char* ClassName();
    virtual int GetError(char* buf,size_t buflen);
    int Ibrd(char* buf,size_t len);
    int Ibwrt(char* buf,size_t len);
    virtual int Ioctl(int cmd,void* args);
    int IsOpen();
    int Read(char* buf,size_t len);
    int Write(char* buf,size_t len);

    static int FindListeners(int board = 0);

};
